/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.figures;


import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;

import com.cea.papyrus.core.PapyrusPlugin;

/**
 * display only a string.
 */
public class StringFigure extends Label {

	/**
	 * 
	 */
	String name="";
	protected String stereotypes="";

	/**
	 * 
	 * 
	 * @param name 
	 */
	public StringFigure(String name)
	{ 
		super(name);
		FontData[] font={new FontData("Arial", 9, SWT.NORMAL)};
		setFont(PapyrusPlugin.fontManager.get(font));
		this.setBackgroundColor(PapyrusPlugin.colorManager.get(new RGB(178,155,203)));

	}

	/**
	 * display the property.
	 */
	protected void display(){
		setText(stereotypes+" "+name);
	}
	
	public void setName(String text){
		name=text;
		display();
	}
	/*
	 * (non-Javadoc)
	 * @see org.eclipse.draw2d.Figure#setBounds(org.eclipse.draw2d.geometry.Rectangle)
	 */
	/**
	 * 
	 * 
	 * @param rect 
	 */
	@Override
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);

	}
	public void setStereotypes(String st){
		if (st==null) {
			this.stereotypes="";
		} else {
			this.stereotypes=PapyrusPlugin.ST_LEFT+st+PapyrusPlugin.ST_RIGHT;
		}
		display();
	}
	
	/**
	 * 
	 */
	public void setActive(){
		this.setOpaque(true);
	}
	
	/**
	 * 
	 */
	public void setUnactive(){
		this.setOpaque(false);
	}

}
